package com.leather.admin.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.leather.admin.entity.Admin;
import com.leather.admin.entity.Permission;
import com.leather.admin.vo.AdminRoleVo;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

/**
 * @author kevin
 */
public interface AdminMapper extends BaseMapper<Admin> {


    /**
     * 冻结管理员
     *
     * @param adminId
     * @return
     */

    @Update("update admin set flag = 1 where id = #{adminId}")
    int fronzenAdmin(@Param("adminId") int adminId);


    /**
     * 解冻管理员
     *
     * @param adminId
     * @return
     */
    @Update("update admin set flag = 0 where id = #{adminId}")
    int unFronzenAdmin(@Param("adminId")int adminId);


    @Select("select a.* from permission a,role_permission b ,admin c  where c.role_id = b.role_id and a.id = b.permission_id and c.admin_name = #{adminName}")
    List<Permission> getAdminPermissions(@Param("adminName") String adminName);



    @Select("select a.id,admin_name,role_name from admin a,role b where a.role_id = b.id")
    List<AdminRoleVo> getAdmin();
}